<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="<%=basePath %>/resource/js/common-css-js.js"></script>
<title>添加货物</title>
</head>
<body>
	<div class="panel-body" style="padding-bottom:0px;">
		<form class="layui-form">
		  <div class="layui-form-item">
			  <input type="text" name="goodsListProductName" lay-verify="required" placeholder="货物名称" autocomplete="off" class="layui-input">
		  </div>
		  <div class="layui-form-item">
			  <input type="text" name="goodsListProductAmount" lay-verify="required|intNumber" placeholder="货物数量" autocomplete="off" class="layui-input">
		  </div>
		  <div class="layui-form-item">
			  <input type="text" name="goodsListProductUnit" lay-verify="required|" placeholder="货物单位" autocomplete="off" class="layui-input">
		  </div>
		  <div class="layui-form-item">
		    <select name="goodsListProductClass" lay-verify="required">
		    </select>
      	  </div>
		  <div class="layui-form-item">
		      <select id="storageId" name="goodsListStorageId" required lay-verify="required">
		      </select>
		  </div>
		  <%@include file="/admin/commonsPage/submit-reset.html" %>
		</form>
	</div>
	<script type="text/javascript">
	
		var storageEle = $("#storageId");
		
		if(parent.storagePositionData.length > 0){
			//生成货架选项
			for(var i = 0;i<parent.storagePositionData.length;i++){
				storageEle.append(
					"<option value='"+parent.storagePositionData[i].stgPosId+"'>"+
					parent.storagePositionData[i].stgPosMark+"("+parent.storagePositionData[i].stgPosNature+")"+
					"</option>"
				)
			}
		}else {
			fixedAlert("全部货架都已存放满,请去清理货架!",0,true);
		}
		
		renderSelectedOption($("[name='goodsListProductClass']"),parent.productClass);
		
		form.render();
		
		form.on('submit(submitForm)',function(data){
			
			//设置id自增,因为可能多次添加,所以变量的作用域范围要放到父类
			data.field.goodsListProductId = ++parent.countIndex;
			
			//Bootstrap-table提供的方法 往表格后面追加一条数据
			parent.cTable.bootstrapTable('append',$.parseJSON(JSON.stringify(data.field)));
			
			var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
			parent.layer.close(index); //再执行关闭 
			
			return false;
		})
	</script>
</body>
</html>